//https://api.dartlang.org/stable/2.2.0/dart-convert/JsonCodec-class.html
import 'dart:convert';

//该类用来进行字符串和json之间的转换
main() {
 JsonCodec json= new JsonCodec();

 //方法

 //decode(String source, { dynamic reviver(Object key, Object value) }) → dynamic    --字符串转成json对象
dynamic obj=json.decode('{"name":"tom","age":18}');
print(obj['name']);

//encode(Object value, { dynamic toEncodable(dynamic object) }) → String -- obj转成json字符串
List list=["a","b","c"];
Map map={'name':'tom','age':18};
dynamic str1=json.encode(list);
dynamic str2=json.encode(map);
print('list--'+str1);
print('map--'+str2);

}